﻿using CinemaMaestro.BusinessLayer.Contracts;
using CinemaMaestro.DataLayer.Contracts;
using CinemaMaestro.DataLayer.Contracts.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CinemaMaestro.BusinessLayer
{
    public class Cinemas : BusinessObjectBase, ICinemas
    {
        public Cinemas(IUnitOfWork uow)
            : base(uow)
        { }

        public Cinema Create(Cinema cinema)
        {
            var createdCinema = _uow.CinemaRepository.Create(cinema);
            _uow.SaveChanges();
            return createdCinema;
        }

        public bool Delete(int id)
        {
            var deleted = _uow.CinemaRepository.Delete(id);
            _uow.SaveChanges();
            return deleted;
        }

        public IQueryable<Cinema> Read()
        {
            return _uow.CinemaRepository.Read();
        }

        public void Update(Cinema entity)
        {
            _uow.CinemaRepository.Update(entity);
            _uow.SaveChanges();
        }
    }
}
